module.exports = `
<template>
<div class="login">
  <div class="login-box">
    <div class="header">
      <div class="title">
        <span class="text">{{{registerTitle}}}</span>
        <span class="triangle"></span>
      </div>
    </div>
    <div class="content">
      <div class="mobile-box">
        <input
          id="phone"
          class="input first"
          v-model="mobile"
          type="text"
          autocomplete="off"
          placeholder="请输入手机号"
        />
        <div class="get-verify-code J_verify_code" @click="handleGetCode">获取验证码</div>
      </div>

      <input
        id="verifycode"
        class="input"
        v-model="validCode"
        type="username"
        placeholder="请输入验证码"
        autocomplete="off"
      />

      <input
        id="password"
        class="input"
        v-model="password"
        :type="isSetPwd ? 'password': 'text'"
        placeholder="请输入密码"
        autocomplete="off"
      />

      <input
        id="comfirmPwd"
        class="input"
        v-model="confirmPassword"
        :type="isSetPwd ? 'password': 'text'"
        placeholder="确认密码"
        autocomplete="off"
      />

      <input
        id="invitePhone"
        class="input"
        v-model="inviteMobile"
        type="text"
        placeholder="输入邀请手机"
        autocomplete="off"
      />
    </div>
    <div class="option">
      <div class="register-btn">
        <el-checkbox v-model="registerProtocol">
          <a :href="register_link" target="_blank">注册协议</a>
        </el-checkbox>
      </div>
      <div class="login-submit-btn" @click="handleRegister">注册</div>
    </div>
  </div>
</div>
</template>

<script>
import common from "@/utils/jhTools"; //工具函数
import API from "@/utils/api_config.js"; //引入api
export default {
name: "login",
data() {
  return {
    mobile: "",
    validCode: "",
    password: "",
    confirmPassword: "",
    inviteMobile: "", //邀请手机
    registerProtocol: false, //注册协议
    allowGetCode: true, //允许获取验证码
    isSetPwd: false, //是否设置密码格式

    register_link:
      "https://app.aifencang.com/sys/#/store_register_protocol_content", //注册协议查看链接
  };
},

mounted() {
  setTimeout(() => {
    this.isSetPwd = true;
  }, 1000);
},
methods: {
  //验证码动画
  handleAllowGetCode(time) {
    clearInterval(timer);
    var count = time;
    this.allowGetCode = false;
    var timer = setInterval(() => {
      count--;
      $(".J_verify_code").text(count + "秒后重新获取");
      if (count == 0) {
        clearInterval(timer);
        $(".J_verify_code").text("获取验证码");
        this.allowGetCode = true;
      }
    }, 1000);
  },

  //验证码获取
  handleGetCode() {
    if (!common.checkPhoneNum(this.mobile)) {
      this.$alert("请输入正确手机号", "提示", {
        confirmButtonText: "确定",
        callback: (action) => {},
      });
      return;
    }
    if (!this.allowGetCode) {
      return;
    }
    this.handleAllowGetCode(5 * 60); //倒计时
    if (!this.mobile) {
      this.$alert("请填写手机号码", "提示", {
        confirmButtonText: "确定",
        callback: (action) => {},
      });
      return;
    }
    var url = {{{getPhoneVerifyCode}}};
    var data = {
      mobile: this.mobile,
    };
    console.log("参数", data);
    common.get(
      url,
      null,
      data,
      (res) => {
        console.log("结果", res);
        if (res.code == 200) {
          this.$message({
            type: "success",
            message: "获取成功！验证码15分钟内有效.",
          });
        } else {
          this.$message({
            type: "success",
            message: "获取失败，请检查网络!",
          });
        }
      },
      (err) => {
        console.log(err);
      }
    );
  },

  //注册提交
  handleRegister() {
    //组合
    let url = {{{registerApi}}}

    //检查获取
    var data = common.checkInputTool({
      tThis: this,
      dataArr: [
        "mobile",
        "validCode",
        "password",
        "confirmPassword",
        // "inviteMobile",
      ],
      tipsObj: {
        mobile: "手机号",
        validCode: "验证码",
        password: "密码",
        confirmPassword: "确认密码",
        // inviteMobile: "邀请人手机号",
      },
    });
    if (!data) return;
    //验证手机
    if (!common.checkPhoneNum(this.mobile)) {
      this.$alert("请输入正确手机号", "提示", {
        confirmButtonText: "确定",
        callback: (action) => {},
      });
      return;
    }
    if (this.inviteMobile && !common.checkPhoneNum(this.inviteMobile)) {
      //邀请手机必填
      this.$alert("请输入正确邀请手机", "提示", {
        confirmButtonText: "确定",
        callback: (action) => {},
      });
      return;
    }
    if (!this.registerProtocol) {
      this.$alert("请勾选注册协议", "提示", {
        confirmButtonText: "确定",
        callback: (action) => {},
      });
      return;
    }
    console.log(data);
    console.log("参数", data);
    common.post(
      url,
      data,
      null,
      (res) => {
        console.log("结果", res);
        if (res.code == 200) {
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          setTimeout(() => {
            this.$router.push({
              path: "/login",
            });
          }, 1000);
        } else if (res.error == "商户手机号已注册请直接登录。") {
          this.$message({
            type: "success",
            message: res.error,
          });
          setTimeout(() => {
            this.$router.push({
              path: "/login",
            });
          }, 1000);
        } else {
          this.$alert(res.error, "提示", {
            confirmButtonText: "确定",
            callback: (action) => {},
          });
        }
      },
      (err) => {
        console.log(err);
      }
    );
  },
},
};
</script>

<style lang="scss" scoped>
// @import '~styles/mixins.scss';
// @import '~styles/variables.scss';

.login {
width: 100%;
height: 100%;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
}

.login-box {
width: 421px;
min-height: 394px;
line-height: 20px;
border-radius: 4px;
text-align: center;
border: 1px solid rgba(219, 215, 219, 1);
padding-bottom: 90px;

.header {
  position: relative;
  height: 144px;
  border-width: 0;

  .title {
    position: absolute;
    left: -20px;
    top: 50px;
    width: 409px;
    height: 60px;
    line-height: 20px;
    border-radius: 1px;
    background-color: #4e6ef2;
    text-align: center;

    .text {
      position: absolute;
      top: 17px;
      left: 60px;
      min-width: 60px;
      height: 30px;
      line-height: 30px;
      color: rgba(255, 255, 255, 1);
      font-size: 18px;
      text-align: center;
      font-family: Roboto;
    }

    .triangle {
      position: absolute;
      bottom: -20px;
      left: -1px;
      width: 0;
      height: 0;
      border: 10px solid transparent;
      border-top-color: rgba(106, 122, 153, 1);
      border-right-color: rgba(106, 122, 153, 1);
    }
  }
}

.content {
  .input {
    padding-left: 20px;
    width: 343px;
    height: 53px;
    border-radius: 4px;
    color: rgba(136, 136, 136, 1);
    font-size: 14px;
    text-align: left;
    font-family: Roboto;
    border: 1px solid rgba(222, 222, 222, 1);
    box-sizing: border-box;
    margin-top: 20px;
    outline-color: #ccc;
  }

  .first {
    margin-top: 0;
  }

  .mobile-box {
    position: relative;
    .get-verify-code {
      position: absolute;
      top: 8px;
      right: 50px;
      cursor: pointer;
      border: 1px solid #ddd;
      font-size: 14px;
      border-radius: 6px;
      padding: 8px;
      color: #888888;
    }
    .get-verify-code:hover {
      opacity: 0.8;
    }
  }
}

.option {
  position: relative;
  height: 60px;

  .register-btn {
    position: absolute;
    top: 21px;
    left: 50px;
    width: 100%;

    color: rgba(9, 126, 242, 1);
    font-size: 14px;
    font-family: SourceHanSansSC-regular;
    width: 30px;
    height: 26px;
  }

  .login-submit-btn {
    position: absolute;
    top: 52px;
    left: 38px;
    width: 344px;
    height: 55px;
    line-height: 55px;
    border-radius: 4px;
    background-color: #4e6ef2;
    color: rgba(255, 255, 255, 1);
    font-size: 18px;
    text-align: center;
    font-family: Roboto;
    border: 1px solid rgba(222, 222, 222, 1);
    cursor: pointer;
    opacity: 0.9;
  }

  .login-submit-btn:hover {
    opacity: 1;
  }
}
}
</style>
`